package com.seeTools.next.service.sys.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.seeTools.next.api.entity.sys.SysRoleMenu;
import com.seeTools.next.common.core.PageQuery;
import com.seeTools.next.mapper.sys.SysRoleMenuMapper;
import com.seeTools.next.service.BaseServiceImpl;
import com.seeTools.next.service.sys.ISysRoleMenuService;
import com.seeTools.next.util.PageQueryHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 角色菜单关联表 服务实现类
 * </p>
 *
 * @author FallenDust
 * @since 2023-05-15
 */
@Service
public class SysRoleMenuServiceImpl extends BaseServiceImpl<SysRoleMenuMapper, SysRoleMenu> implements ISysRoleMenuService {

    @Resource
    private PageQueryHelper<SysRoleMenu> pageQueryHelper;

    @Override
    public Page<SysRoleMenu> pageInfo(PageQuery<SysRoleMenu> pageQuery) {
        SysRoleMenu params = pageQuery.getParams();
        // 根据查询参数组装查询wrapper
        QueryWrapper<SysRoleMenu> queryWrapper = new QueryWrapper<>();
        LambdaQueryWrapper<SysRoleMenu> lambdaQueryWrapper = queryWrapper.lambda();
        return pageQueryHelper.pageInfo(this, pageQuery, queryWrapper);
    }

    @Override
    public void removeByRoleId(Long roleId) {
        this.remove(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, roleId));
    }
}
